﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FangDuShi_API.BLL
{
    /// <summary>
    /// 中介公司 逻辑类
    /// </summary>
    public class Agency
    {
        /// <summary>
        /// 中介公司DAL
        /// </summary>
        private DAL.Agency agencyDAL = new DAL.Agency();
        public Agency()
        { }
        /// <summary>
        /// 获得地区的中介公司列表
        /// </summary>
        public List<FangDuShi_API.Model.Agency> GetList(string districtNo)
        {
            DataSet ds = agencyDAL.GetList(districtNo);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<FangDuShi_API.Model.Agency> DataTableToList(DataTable dt)
        {
            List<FangDuShi_API.Model.Agency> modelList = new List<FangDuShi_API.Model.Agency>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                FangDuShi_API.Model.Agency model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = agencyDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
